home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / cloud9.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  9KB  |  299 lines

  1. /***************************************************************************
  2.  
  3.   Cloud9 (prototype) driver.
  4.  
  5.   This hardware is yet another variant of the Centipede/Millipede hardware,
  6.   but as you can see there are some significant deviations...
  7.  
  8.   0000            R/W        X index into the bitmap
  9.   0001            R/W        Y index into the bitmap
  10.   0002            R/W        Current bitmap pixel value
  11.   0003-05FF        R/W        RAM
  12.   0600-3FFF        R/W        Bitmap RAM bank 0 (and bank 1 ?)
  13.   5000-5073        R/W        Motion Object RAM
  14.   5400            W        Watchdog
  15.   5480            W        IRQ Acknowledge
  16.   5500-557F        W        Color RAM (9 bits, 4 banks, LSB of Blue is addr&$40)
  17.  
  18.   5580            W        Auto-increment X bitmap index (~D7)
  19.   5581            W        Auto-increment Y bitmap index (~D7)
  20.   5584            W        VRAM Both Banks - (D7) seems to allow writing to both banks
  21.   5585            W        Invert screen?
  22.   5586            W        VRAM Bank select?
  23.   5587            W        Color bank select
  24.  
  25.   5600            W        Coin Counter 1 (D7)
  26.   5601            W        Coin Counter 2 (D7)
  27.   5602            W        Start1 LED (~D7)
  28.   5603            W        Start2 LED (~D7)
  29.  
  30.   5680            W        Force Write to EAROM?
  31.   5700            W        EAROM Off?
  32.   5780            W        EAROM On?
  33.  
  34.   5800            R        IN0 (D7=Vblank, D6=Right Coin, D5=Left Coin, D4=Aux, D3=Self Test)
  35.   5801            R        IN1 (D7=Start1, D6=Start2, D5=Fire, D4=Zap)
  36.   5900            R        Trackball Vert
  37.   5901            R        Trackball Horiz
  38.  
  39.   5A00-5A0F        R/W        Pokey 1
  40.   5B00-5B0F        R/W        Pokey 2
  41.   5C00-5CFF        W        EAROM
  42.   6000-FFFF        R        Program ROM
  43.  
  44.  
  45.  
  46. If you have any questions about how this driver works, don't hesitate to
  47. ask.  - Mike Balfour (mab22@po.cwru.edu)
  48. ***************************************************************************/
  49.  
  50. #include "driver.h"
  51. #include "vidhrdw/generic.h"
  52.  
  53. WRITE_HANDLER( cloud9_paletteram_w );
  54. READ_HANDLER( cloud9_bitmap_regs_r );
  55. WRITE_HANDLER( cloud9_bitmap_regs_w );
  56. WRITE_HANDLER( cloud9_bitmap_w );
  57. extern void cloud9_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  58.  
  59. extern unsigned char *cloud9_vram2;
  60. extern unsigned char *cloud9_bitmap_regs;
  61. extern unsigned char *cloud9_auto_inc_x;
  62. extern unsigned char *cloud9_auto_inc_y;
  63. extern unsigned char *cloud9_both_banks;
  64. extern unsigned char *cloud9_vram_bank;
  65. extern unsigned char *cloud9_color_bank;
  66.  
  67.  
  68. static unsigned char *nvram;
  69. static size_t nvram_size;
  70.  
  71. static void nvram_handler(void *file,int read_or_write)
  72. {
  73.     if (read_or_write)
  74.         osd_fwrite(file,nvram,nvram_size);
  75.     else
  76.     {
  77.         if (file)
  78.             osd_fread(file,nvram,nvram_size);
  79.         else
  80.             memset(nvram,0,nvram_size);
  81.     }
  82. }
  83.  
  84.  
  85. static WRITE_HANDLER( cloud9_led_w )
  86. {
  87. //    osd_led_w(offset,~data >> 7);
  88. }
  89.  
  90.  
  91.  
  92. static struct MemoryReadAddress readmem[] =
  93. {
  94.     { 0x0000, 0x0002, cloud9_bitmap_regs_r },
  95.     { 0x0003, 0x05ff, MRA_RAM },
  96.     { 0x0600, 0x3fff, MRA_RAM },
  97.     { 0x5500, 0x557f, MRA_RAM },
  98.     { 0x5800, 0x5800, input_port_0_r },
  99.     { 0x5801, 0x5801, input_port_1_r },
  100.     { 0x5900, 0x5900, input_port_2_r },
  101.     { 0x5901, 0x5901, input_port_3_r },
  102.     { 0x5a00, 0x5a0f, pokey1_r },
  103.     { 0x5b00, 0x5b0f, pokey2_r },
  104.     { 0x5c00, 0x5cff, MRA_RAM },    /* EAROM */
  105.     { 0x6000, 0xffff, MRA_ROM },
  106.     { -1 }    /* end of table */
  107. };
  108.  
  109. static struct MemoryWriteAddress writemem[] =
  110. {
  111.     { 0x0000, 0x0002, cloud9_bitmap_regs_w, &cloud9_bitmap_regs },
  112.     { 0x0003, 0x05ff, MWA_RAM },
  113.     { 0x0600, 0x3fff, cloud9_bitmap_w, &videoram, &videoram_size },
  114.     { 0x5000, 0x50ff, MWA_RAM, &spriteram },
  115.     { 0x5400, 0x5400, watchdog_reset_w },
  116.     { 0x5480, 0x5480, MWA_NOP },    /* IRQ Ack */
  117.     { 0x5500, 0x557f, cloud9_paletteram_w, &paletteram },
  118.     { 0x5580, 0x5580, MWA_RAM, &cloud9_auto_inc_x },
  119.     { 0x5581, 0x5581, MWA_RAM, &cloud9_auto_inc_y },
  120.     { 0x5584, 0x5584, MWA_RAM, &cloud9_both_banks },
  121.     { 0x5586, 0x5586, MWA_RAM, &cloud9_vram_bank },
  122.     { 0x5587, 0x5587, MWA_RAM, &cloud9_color_bank },
  123.     { 0x5600, 0x5601, coin_counter_w },
  124.     { 0x5602, 0x5603, cloud9_led_w },
  125.     { 0x5a00, 0x5a0f, pokey1_w },
  126.     { 0x5b00, 0x5b0f, pokey2_w },
  127.     { 0x5c00, 0x5cff, MWA_RAM, &nvram, &nvram_size },
  128.     { 0x6000, 0xffff, MWA_ROM },
  129.     { 0x10600,0x13fff, MWA_RAM, &cloud9_vram2 },
  130.     { -1 }    /* end of table */
  131. };
  132.  
  133.  
  134.  
  135. INPUT_PORTS_START( cloud9 )
  136.     PORT_START    /* IN0 */
  137.     PORT_BIT ( 0x07, IP_ACTIVE_LOW, IPT_UNKNOWN )
  138.     PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
  139.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
  140.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
  141.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
  142.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
  143.  
  144.     PORT_START      /* IN1 */
  145.     PORT_BIT ( 0x0F, IP_ACTIVE_LOW, IPT_UNKNOWN )
  146.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 )
  147.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
  148.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START2 )
  149.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  150.  
  151.     PORT_START      /* IN2 */
  152.     PORT_ANALOG( 0xff, 0x7f, IPT_TRACKBALL_Y | IPF_REVERSE, 30, 30, 0, 0 )
  153.  
  154.     PORT_START      /* IN3 */
  155.     PORT_ANALOG( 0xff, 0x7f, IPT_TRACKBALL_X, 30, 30, 0, 0 )
  156.  
  157.     PORT_START    /* IN4 */ /* DSW1 */
  158.     PORT_BIT ( 0xFF, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  159.  
  160.     PORT_START    /* IN5 */ /* DSW2 */
  161.     PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  162.     PORT_DIPNAME( 0x06, 0x04, DEF_STR( Coinage ) )
  163.     PORT_DIPSETTING (   0x06, DEF_STR( 2C_1C ) )
  164.     PORT_DIPSETTING (   0x04, DEF_STR( 1C_1C ) )
  165.     PORT_DIPSETTING (   0x02, DEF_STR( 1C_2C ) )
  166.     PORT_DIPSETTING (   0x00, DEF_STR( Free_Play ) )
  167.     PORT_DIPNAME(0x18,  0x00, "Right Coin" )
  168.     PORT_DIPSETTING (   0x00, "*1" )
  169.     PORT_DIPSETTING (   0x08, "*4" )
  170.     PORT_DIPSETTING (   0x10, "*5" )
  171.     PORT_DIPSETTING (   0x18, "*6" )
  172.     PORT_DIPNAME(0x20,  0x00, "Middle Coin" )
  173.     PORT_DIPSETTING (   0x00, "*1" )
  174.     PORT_DIPSETTING (   0x20, "*2" )
  175.     PORT_DIPNAME(0xC0,  0x00, "Bonus Coins" )
  176.     PORT_DIPSETTING (   0xC0, "4 coins + 2 coins" )
  177.     PORT_DIPSETTING (   0x80, "4 coins + 1 coin" )
  178.     PORT_DIPSETTING (   0x40, "2 coins + 1 coin" )
  179.     PORT_DIPSETTING (   0x00, "None" )
  180. INPUT_PORTS_END
  181.  
  182. static struct GfxLayout charlayout =
  183. {
  184.     8,8,    /* 8*8 characters */
  185.     128,    /* 128 characters */
  186.     4,    /* 4 bits per pixel */
  187.     { 0x3000*8, 0x2000*8, 0x1000*8, 0 },    /* the four bitplanes are separated */
  188.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  189.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  190.     16*8    /* every char takes 8 consecutive bytes, then skip 8 */
  191. };
  192.  
  193. static struct GfxLayout spritelayout =
  194. {
  195.     16,16,    /* 16*16 sprites */
  196.     64,    /* 64 sprites */
  197.     4,    /* 4 bits per pixel */
  198.     { 0x3000*8, 0x2000*8, 0x1000*8, 0x0000*8 },    /* the four bitplanes are separated */
  199.     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
  200.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8,
  201.             16*8, 18*8, 20*8, 22*8, 24*8, 26*8, 28*8, 30*8 },
  202.     32*8    /* every sprite takes 32 consecutive bytes */
  203. };
  204.  
  205.  
  206. static struct GfxDecodeInfo gfxdecodeinfo[] =
  207. {
  208.     { REGION_GFX1, 0x0800, &charlayout,   0, 4 },
  209.     { REGION_GFX1, 0x0808, &charlayout,   0, 4 },
  210.     { REGION_GFX1, 0x0000, &spritelayout, 0, 4 },
  211.     { -1 } /* end of array */
  212. };
  213.  
  214.  
  215.  
  216. static struct POKEYinterface pokey_interface =
  217. {
  218.     2,    /* 2 chips */
  219.     1500000,    /* 1.5 MHz??? */
  220.     { 50, 50 },
  221.     /* The 8 pot handlers */
  222.     { 0, 0 },
  223.     { 0, 0 },
  224.     { 0, 0 },
  225.     { 0, 0 },
  226.     { 0, 0 },
  227.     { 0, 0 },
  228.     { 0, 0 },
  229.     { 0, 0 },
  230.     /* The allpot handler */
  231.     { input_port_4_r, input_port_5_r },
  232. };
  233.  
  234.  
  235. static struct MachineDriver machine_driver_cloud9 =
  236. {
  237.     /* basic machine hardware */
  238.     {
  239.         {
  240.             CPU_M6502,
  241.             12096000/8,    /* 1.512 Mhz?? */
  242.             readmem,writemem,0,0,
  243.             interrupt,4
  244.         }
  245.     },
  246.     60, 1460,    /* frames per second, vblank duration??? */
  247.     1,    /* single CPU, no need for interleaving */
  248.     0,
  249.  
  250.     /* video hardware */
  251.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 32*8-1 },
  252.     gfxdecodeinfo,
  253.     64, 64,
  254.     0,
  255.  
  256.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  257.     0,
  258.     generic_bitmapped_vh_start,
  259.     generic_bitmapped_vh_stop,
  260.     cloud9_vh_screenrefresh,
  261.  
  262.     /* sound hardware */
  263.     0,0,0,0,
  264.     {
  265.         {
  266.             SOUND_POKEY,
  267.             &pokey_interface
  268.         }
  269.     },
  270.  
  271.     nvram_handler
  272. };
  273.  
  274.  
  275. /***************************************************************************
  276.  
  277.   Game ROMs
  278.  
  279. ***************************************************************************/
  280.  
  281. ROM_START( cloud9 )
  282.     ROM_REGION( 0x14000, REGION_CPU1 )    /* 64k for code + extra VRAM space */
  283.     ROM_LOAD( "c9_6000.bin", 0x6000, 0x2000, 0xb5d95d98 )
  284.     ROM_LOAD( "c9_8000.bin", 0x8000, 0x2000, 0x49af8f22 )
  285.     ROM_LOAD( "c9_a000.bin", 0xa000, 0x2000, 0x7cf404a6 )
  286.     ROM_LOAD( "c9_c000.bin", 0xc000, 0x2000, 0x26a4d7df )
  287.     ROM_LOAD( "c9_e000.bin", 0xe000, 0x2000, 0x6e663bce )
  288.  
  289.     ROM_REGION( 0x4000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  290.     ROM_LOAD( "c9_gfx0.bin", 0x0000, 0x1000, 0xd01a8019 )
  291.     ROM_LOAD( "c9_gfx1.bin", 0x1000, 0x1000, 0x514ac009 )
  292.     ROM_LOAD( "c9_gfx2.bin", 0x2000, 0x1000, 0x930c1ade )
  293.     ROM_LOAD( "c9_gfx3.bin", 0x3000, 0x1000, 0x27e9b88d )
  294. ROM_END
  295.  
  296.  
  297.  
  298. GAMEX( 1983, cloud9, 0, cloud9, cloud9, 0, ROT0, "Atari", "Cloud 9 (prototype)", GAME_NO_COCKTAIL )
  299.